package cn.wen.bases.framework.struts.interceptor;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import cn.wen.bases.framework.struts.UtilsOfStruts;

/**
 * Title：访问信息统计拦截器
 * <p>
 * Description：
 * <p>
 * Copyright：Copyright (c) 2010-2012
 * 
 * @author <a href="mailto:ct_wen@qq.com">ctwen</a>, 温承瑭
 * @version Revision：1.0 Date：2010/11/15 Description：初完成。
 *          <p>
 */
public class ModuleAccessInterceptor extends AbstractInterceptor {

    private static final long serialVersionUID = 1417687932106387799L;
    
    private Logger log = Logger.getLogger(getClass());

    /**
     * <pre>
     * 访问信息统计。
     * </pre>
     * 
     * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
     */
    @Override
    public String intercept(ActionInvocation ai) throws Exception {
	String requestURI = UtilsOfStruts.getHttpServletRequest().getRequestURI();
	log.info("Accessing URL:" + requestURI);
	/*if (log.isDebugEnabled()) {
	log.debug("参数展示：");
	HttpServletRequest request = ServletActionContext.getRequest();
	Map m = request.getParameterMap();
	Iterator it = m.entrySet().iterator();
	//String paramString = "";
	while (it.hasNext()) {
		Map.Entry entry = (Map.Entry) it.next();
		String key = (String) entry.getKey();
		//String value = HelperOfEncode.toSpecificEncodingFromOldEncoding(Arrays.toString((Object[]) entry.getValue()), HelperOfEncode.ISO_8859_1, HelperOfEncode.UTF_8);
		String value = Arrays.toString((Object[]) entry.getValue());
		log.debug(HelperOfString.format("Setting params {0} => [ {1} ]\n", key, value));
	}
	//log.debug(paramString);
	}*/
	return ai.invoke();
    }

}
